package com.jeesite.springai.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("")
class MyController {

	@Autowired
	private ChatModel myChatModel;

	@GetMapping("/ai")
	String generation(String userInput) {
		ChatClient.Builder builder = ChatClient.builder(myChatModel);
		ChatClient chatClient = ChatClient.create(myChatModel);
		return chatClient.prompt().user(userInput).call().content();
	}

	@GetMapping("/ai02")
	String generation01(String userInput) {
		ChatClient.Builder builder = ChatClient.builder(myChatModel);
		ChatClient chatClient = ChatClient.create(myChatModel);
		ChatResponse chatResponse = chatClient.prompt().user(userInput).call().chatResponse();

		return chatResponse.toString();
	}

}